package com.feri.fss.service.impl;

import com.feri.fss.common.vo.PageBean;
import com.feri.fss.common.vo.R;
import com.feri.fss.dao.AdminLogDao;
import com.feri.fss.entity.AdminLog;
import com.feri.fss.service.intf.AdminLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Feri
 * @date 2021/12/17 14:20
 * @description:TODO
 */
@Service
public class AdminLogServiceImpl implements AdminLogService {
    @Autowired
    private AdminLogDao dao;

    @Override
    public R save(AdminLog log) {
        if(dao.insert(log)>0){
            return R.ok();
        }else {
            return R.fail("亲，网络异常，请检查网络！");
        }
    }

    @Override
    public PageBean queryPage(int page, int limit) {
        //开启查询，设置分页信息
        PageHelper.startPage(page, limit);
        //获取查询结果
        PageInfo<AdminLog> pageInfo=new PageInfo<>(dao.selectAll());
        //返回分页数据，符合Layui的要求
        return new PageBean(pageInfo.getTotal(),pageInfo.getList());
    }
}
